Skip to content

Commit

Permalink
Try configuring BugSystem directly after installation. Refs #15
Browse files Browse the repository at this point in the history
this should fail b/c the payload is missing the `full_html` field
  • Loading branch information
atodorov committed Jul 13, 2020
1 parent 6cea700 commit e79b0ab
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 0 deletions.
49 changes: 49 additions & 0 deletions tcms_github_app/tests/test_views.py
Expand Up @@ -378,6 +378,7 @@ def tearDown(self):
for tenant in [self.public_tenant, self.private_tenant, self.tenant]:
with tenant_context(tenant):
Product.objects.all().delete()
BugSystem.objects.all().delete()

def test_sender_not_in_db(self):
with schema_context('public'):
Expand Down Expand Up @@ -447,6 +448,12 @@ def test_sender_only_has_access_to_public(self):
with tenant_context(tenant):
self.assertFalse(Product.objects.filter(name='kiwitcms-bot/example').exists())
self.assertFalse(Product.objects.filter(name='kiwitcms-bot/test').exists())
self.assertFalse(
BugSystem.objects.filter(
name='GitHub Issues for kiwitcms-bot/example').exists())
self.assertFalse(
BugSystem.objects.filter(
name='GitHub Issues for kiwitcms-bot/test').exists())

payload = """
{
Expand Down Expand Up @@ -507,12 +514,24 @@ def test_sender_only_has_access_to_public(self):
with schema_context('public'):
self.assertTrue(Product.objects.filter(name='kiwitcms-bot/example').exists())
self.assertTrue(Product.objects.filter(name='kiwitcms-bot/test').exists())
self.assertTrue(
BugSystem.objects.filter(
name='GitHub Issues for kiwitcms-bot/example').exists())
self.assertTrue(
BugSystem.objects.filter(
name='GitHub Issues for kiwitcms-bot/test').exists())

# and not on other tenants
for tenant in [self.tenant, self.private_tenant]:
with tenant_context(tenant):
self.assertFalse(Product.objects.filter(name='kiwitcms-bot/example').exists())
self.assertFalse(Product.objects.filter(name='kiwitcms-bot/test').exists())
self.assertFalse(
BugSystem.objects.filter(
name='GitHub Issues for kiwitcms-bot/example').exists())
self.assertFalse(
BugSystem.objects.filter(
name='GitHub Issues for kiwitcms-bot/test').exists())

def test_sender_only_has_access_to_private_tenant(self):
with schema_context('public'):
Expand All @@ -524,6 +543,12 @@ def test_sender_only_has_access_to_private_tenant(self):
with tenant_context(tenant):
self.assertFalse(Product.objects.filter(name='kiwitcms-bot/example').exists())
self.assertFalse(Product.objects.filter(name='kiwitcms-bot/test').exists())
self.assertFalse(
BugSystem.objects.filter(
name='GitHub Issues for kiwitcms-bot/example').exists())
self.assertFalse(
BugSystem.objects.filter(
name='GitHub Issues for kiwitcms-bot/test').exists())

payload = """
{
Expand Down Expand Up @@ -585,10 +610,22 @@ def test_sender_only_has_access_to_private_tenant(self):
with tenant_context(tenant):
self.assertFalse(Product.objects.filter(name='kiwitcms-bot/example').exists())
self.assertFalse(Product.objects.filter(name='kiwitcms-bot/test').exists())
self.assertFalse(
BugSystem.objects.filter(
name='GitHub Issues for kiwitcms-bot/example').exists())
self.assertFalse(
BugSystem.objects.filter(
name='GitHub Issues for kiwitcms-bot/test').exists())

with tenant_context(self.private_tenant):
self.assertTrue(Product.objects.filter(name='kiwitcms-bot/example').exists())
self.assertTrue(Product.objects.filter(name='kiwitcms-bot/test').exists())
self.assertTrue(
BugSystem.objects.filter(
name='GitHub Issues for kiwitcms-bot/example').exists())
self.assertTrue(
BugSystem.objects.filter(
name='GitHub Issues for kiwitcms-bot/test').exists())

def test_sender_has_access_to_multiple_tenants(self):
with schema_context('public'):
Expand All @@ -600,6 +637,12 @@ def test_sender_has_access_to_multiple_tenants(self):
with tenant_context(tenant):
self.assertFalse(Product.objects.filter(name='kiwitcms-bot/example').exists())
self.assertFalse(Product.objects.filter(name='kiwitcms-bot/test').exists())
self.assertFalse(
BugSystem.objects.filter(
name='GitHub Issues for kiwitcms-bot/example').exists())
self.assertFalse(
BugSystem.objects.filter(
name='GitHub Issues for kiwitcms-bot/test').exists())

payload = """
{
Expand Down Expand Up @@ -661,6 +704,12 @@ def test_sender_has_access_to_multiple_tenants(self):
with tenant_context(tenant):
self.assertFalse(Product.objects.filter(name='kiwitcms-bot/example').exists())
self.assertFalse(Product.objects.filter(name='kiwitcms-bot/test').exists())
self.assertFalse(
BugSystem.objects.filter(
name='GitHub Issues for kiwitcms-bot/example').exists())
self.assertFalse(
BugSystem.objects.filter(
name='GitHub Issues for kiwitcms-bot/test').exists())


class ApplicationEditTestCase(LoggedInTestCase):
Expand Down
1 change: 1 addition & 0 deletions tcms_github_app/utils.py
Expand Up @@ -132,6 +132,7 @@ def create_installation(data):
with tenant_context(tenant):
for repository in data.payload['repositories']:
_product_from_repo(repository)
_bugtracker_from_repo(repository)


def create_version_from_tag(data):
Expand Down

0 comments on commit e79b0ab

Please sign in to comment.