Skip to content

Commit

Permalink
test: outdated module name in integration tests
Browse files Browse the repository at this point in the history
  • Loading branch information
azzamsa committed Jul 30, 2024
1 parent 1725cbd commit c890f85
Show file tree
Hide file tree
Showing 5 changed files with 48 additions and 44 deletions.
4 changes: 3 additions & 1 deletion .github/workflows/ci_api.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,9 @@ jobs:

- name: Lint
# currently cli is not-maintained
run: just check
run: |
just fmt-check
just lint
test:
name: Test
Expand Down
8 changes: 4 additions & 4 deletions api/tests/integration/test_domain.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import app.helpers.producer
import rkapi.app.helpers.producer


class TestDomain:
Expand All @@ -18,8 +18,8 @@ def test_domain(self, client, mocker):
- List the domain
- Delete the domain
"""
mocker.patch("app.helpers.producer.kafka_producer")
mocker.patch("app.helpers.producer.send")
mocker.patch("rkapi.app.helpers.producer.kafka_producer")
mocker.patch("rkapi.app.helpers.producer.send")
headers = {"X-Api-Key": "123"}

# create user
Expand Down Expand Up @@ -52,5 +52,5 @@ def test_domain(self, client, mocker):

# 4: set_config, set_zone, delegate, delegate (creation)
# 5: unset_config, unset_zone (SOA, NS, NS, CNAME)
assert app.helpers.producer.send.call_count == 9
assert rkapi.app.helpers.producer.send.call_count == 9
assert delete_domain_data.status_code == 204
6 changes: 3 additions & 3 deletions api/tests/integration/test_messages.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import app.helpers.producer
import rkapi.app.helpers.producer
import tests.fixtures.messages as message_fx


Expand All @@ -15,8 +15,8 @@ def test_messages(self, client, monkeypatch, mocker):
- Create a domain (with default SOA,NS,CNAME created)
- Assert the sent command
"""
mocker.patch("app.helpers.producer.kafka_producer")
monkeypatch.setattr(app.helpers.producer, "send", self.fake_send)
mocker.patch("rkapi.app.helpers.producer.kafka_producer")
monkeypatch.setattr(rkapi.app.helpers.producer, "send", self.fake_send)
headers = {"X-Api-Key": "123"}

# create user
Expand Down
38 changes: 20 additions & 18 deletions api/tests/integration/test_record.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import datetime

import app.helpers.helpers
import rkapi.app.helpers.helpers
from rkapi.app.controllers.api import record as record_api
from rkapi.app.helpers import helpers

Expand All @@ -27,8 +27,8 @@ def test_add_record(self, client, mocker):
- Add a record
- Query the db to assure it's created
"""
mocker.patch("app.helpers.producer.kafka_producer")
mocker.patch("app.helpers.producer.send")
mocker.patch("rkapi.app.helpers.producer.kafka_producer")
mocker.patch("rkapi.app.helpers.producer.send")
headers = {"X-Api-Key": "123"}

# create user
Expand Down Expand Up @@ -75,8 +75,8 @@ def test_edit_record(self, client, mocker):
- Edit a record
- Query the db to assure it's edited
"""
mocker.patch("app.helpers.producer.kafka_producer")
mocker.patch("app.helpers.producer.send")
mocker.patch("rkapi.app.helpers.producer.kafka_producer")
mocker.patch("rkapi.app.helpers.producer.send")
headers = {"X-Api-Key": "123"}

# create user
Expand Down Expand Up @@ -125,8 +125,8 @@ def test_edit_record_no_ttl_change(self, client, mocker):
- Create a domain (with default SOA,NS,CNAME created)
- Edit a record with the same TTL
"""
mocker.patch("app.helpers.producer.kafka_producer")
mocker.patch("app.helpers.producer.send")
mocker.patch("rkapi.app.helpers.producer.kafka_producer")
mocker.patch("rkapi.app.helpers.producer.send")
headers = {"X-Api-Key": "123"}

# create user
Expand Down Expand Up @@ -168,8 +168,8 @@ def test_edit_record_with_ttl_change(self, client, mocker):
- Edit a record with the different TTL
- Query the db to assure it's edited
"""
mocker.patch("app.helpers.producer.kafka_producer")
mocker.patch("app.helpers.producer.send")
mocker.patch("rkapi.app.helpers.producer.kafka_producer")
mocker.patch("rkapi.app.helpers.producer.send")
headers = {"X-Api-Key": "123"}

# create user
Expand Down Expand Up @@ -220,8 +220,8 @@ def test_delete_record(self, client, mocker):
- Delete one of the record
- Query the db to assure it's deleted
"""
mocker.patch("app.helpers.producer.kafka_producer")
mocker.patch("app.helpers.producer.send")
mocker.patch("rkapi.app.helpers.producer.kafka_producer")
mocker.patch("rkapi.app.helpers.producer.send")
headers = {"X-Api-Key": "123"}

# create user
Expand Down Expand Up @@ -260,8 +260,8 @@ def test_edit_record_no_ttl_change_MX(self, client, mocker):
- Add MX record
- Edit a record with the same TTL
"""
mocker.patch("app.helpers.producer.kafka_producer")
mocker.patch("app.helpers.producer.send")
mocker.patch("rkapi.app.helpers.producer.kafka_producer")
mocker.patch("rkapi.app.helpers.producer.send")
headers = {"X-Api-Key": "123"}

# create user
Expand Down Expand Up @@ -310,8 +310,8 @@ def test_edit_record_with_ttl_change_MX(self, client, mocker):
- Edit a record with the different TTL
- Query the db to assure it's edited
"""
mocker.patch("app.helpers.producer.kafka_producer")
mocker.patch("app.helpers.producer.send")
mocker.patch("rkapi.app.helpers.producer.kafka_producer")
mocker.patch("rkapi.app.helpers.producer.send")
headers = {"X-Api-Key": "123"}

# create user
Expand Down Expand Up @@ -368,8 +368,8 @@ def test_edit_record_respect_zone_limit(self, client, monkeypatch, mocker):
- Edit a record with the different TXT value until it reaches a limit
- Edit a record with tomorrows date
"""
mocker.patch("app.helpers.producer.kafka_producer")
mocker.patch("app.helpers.producer.send")
mocker.patch("rkapi.app.helpers.producer.kafka_producer")
mocker.patch("rkapi.app.helpers.producer.send")
headers = {"X-Api-Key": "123"}

# create user
Expand Down Expand Up @@ -430,7 +430,9 @@ def fake_soa_time_set():
tomorrow_date = datetime.datetime.now() + datetime.timedelta(days=1)
return tomorrow_date.strftime("%Y%m%d")

monkeypatch.setattr(app.helpers.helpers, "soa_time_set", fake_soa_time_set)
monkeypatch.setattr(
rkapi.app.helpers.helpers, "soa_time_set", fake_soa_time_set
)
data = {
"zone": "company.com",
"owner": "txt1",
Expand Down
36 changes: 18 additions & 18 deletions api/tests/integration/test_rules.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ def test_duplicate_record(self, client, mocker):
- # default CNAME owner is `www`
- Add CNAME record with `www` as owner -> must be FAIL (duplicate record)
"""
mocker.patch("app.helpers.producer.kafka_producer")
mocker.patch("app.helpers.producer.send")
mocker.patch("rkapi.app.helpers.producer.kafka_producer")
mocker.patch("rkapi.app.helpers.producer.send")

headers = {"X-Api-Key": "123"}

Expand Down Expand Up @@ -44,8 +44,8 @@ def test_possible_duplicate_record(self, client, mocker):
- Add CNAME record with `www1` as owner.
- Edit CNAME record with `wwww` as owner and `company.com.` as rdata -> must be FAIL (duplicate record)
"""
mocker.patch("app.helpers.producer.kafka_producer")
mocker.patch("app.helpers.producer.send")
mocker.patch("rkapi.app.helpers.producer.kafka_producer")
mocker.patch("rkapi.app.helpers.producer.send")

headers = {"X-Api-Key": "123"}

Expand Down Expand Up @@ -93,8 +93,8 @@ def test_unique_host(self, client, mocker):
- # default CNAME owner is `www`
- Add CNAME record with `www1` as owner -> must be SUCCESS (unique allowed)
"""
mocker.patch("app.helpers.producer.kafka_producer")
mocker.patch("app.helpers.producer.send")
mocker.patch("rkapi.app.helpers.producer.kafka_producer")
mocker.patch("rkapi.app.helpers.producer.send")

headers = {"X-Api-Key": "123"}

Expand Down Expand Up @@ -130,8 +130,8 @@ def test_not_unique_host(self, client, mocker):
- # default CNAME owner is `www`
- Add CNAME record with `www` as owner -> must be FAIL (duplicate owner)
"""
mocker.patch("app.helpers.producer.kafka_producer")
mocker.patch("app.helpers.producer.send")
mocker.patch("rkapi.app.helpers.producer.kafka_producer")
mocker.patch("rkapi.app.helpers.producer.send")
headers = {"X-Api-Key": "123"}

# create user
Expand Down Expand Up @@ -167,8 +167,8 @@ def test_clash_with_A_owner(self, client, mocker):
- Add A record with `host` as owner
- Add CNAME record with `host` as owner -> must be FAIL (clash with A owner)
"""
mocker.patch("app.helpers.producer.kafka_producer")
mocker.patch("app.helpers.producer.send")
mocker.patch("rkapi.app.helpers.producer.kafka_producer")
mocker.patch("rkapi.app.helpers.producer.send")
headers = {"X-Api-Key": "123"}

# create user
Expand Down Expand Up @@ -213,8 +213,8 @@ def test_duplicate_record(self, client, mocker):
- Add A record with `a1` as owner and `1.1.1.1` as rdata
- Add A record with `a1` as owner and `1.1.1.1` as rdata -> must be FAIL (duplicate record)
"""
mocker.patch("app.helpers.producer.kafka_producer")
mocker.patch("app.helpers.producer.send")
mocker.patch("rkapi.app.helpers.producer.kafka_producer")
mocker.patch("rkapi.app.helpers.producer.send")

headers = {"X-Api-Key": "123"}

Expand Down Expand Up @@ -260,8 +260,8 @@ def test_possible_duplicate_record(self, client, mocker):
- Add A record with `a1` as owner and `2.2.2.2` as rdata
- Edit A record with `a1` as owner and `1.1.1.1` as rdata -> must be FAIL (duplicate record)
"""
mocker.patch("app.helpers.producer.kafka_producer")
mocker.patch("app.helpers.producer.send")
mocker.patch("rkapi.app.helpers.producer.kafka_producer")
mocker.patch("rkapi.app.helpers.producer.send")

headers = {"X-Api-Key": "123"}

Expand Down Expand Up @@ -318,8 +318,8 @@ def test_not_unique_owner(self, client, mocker):
- Add A record with `host` as owner
- Add A record with `host` as owner -> must be SUCCESS (same owner allowed)
"""
mocker.patch("app.helpers.producer.kafka_producer")
mocker.patch("app.helpers.producer.send")
mocker.patch("rkapi.app.helpers.producer.kafka_producer")
mocker.patch("rkapi.app.helpers.producer.send")
headers = {"X-Api-Key": "123"}

# create user
Expand Down Expand Up @@ -363,8 +363,8 @@ def test_clash_with_cname_owner(self, client, mocker):
- Add CNAME record with `host` as owner
- Add A record with `host` as owner -> must be FAIL (clash with CNAME owner)
"""
mocker.patch("app.helpers.producer.kafka_producer")
mocker.patch("app.helpers.producer.send")
mocker.patch("rkapi.app.helpers.producer.kafka_producer")
mocker.patch("rkapi.app.helpers.producer.send")
headers = {"X-Api-Key": "123"}

# create user
Expand Down

0 comments on commit c890f85

Please sign in to comment.