def test_activation_codes(self): with atomic(): models.ActivationCode.objects.create(table=self.table, code='10000000', site_id=1) models.ActivationCode.objects.create(table=self.table, code='10000001', site_id=2) with atomic(): with self.assertRaises(IntegrityError): models.ActivationCode.objects.create(table=self.table, code='10000002', site_id=2) with self.assertRaises(ValidationError): models.ActivationCode.activation_code_validator('123456789') with self.assertRaises(ValidationError): models.ActivationCode.activation_code_validator('1234567') with self.assertRaises(PermissionError): daos.TableDAO(self.table, self.user) table_dao = daos.TableDAO(self.table, self.staff) self.assertEqual(table_dao.get_activation_code_data(), [('2', '10000000'), ('3', '10000001')]) with atomic(): models.ActivationCode.objects.filter(table=self.table).delete() self.table_creation_dao.create_activation_codes() table_dao = daos.TableDAO(self.table, self.staff) self.assertEqual(len(table_dao.get_activation_code_data()), 3)
def test_html_body(self): activation_code_html = model_html.ActivationCodeHtml( daos.TableDAO(table=self.table, user=self.owner)) self.assertEqual( activation_code_html.get_html_table_body(), '<tbody>' '<tr><td>2</td><td>10000000</td></tr>' '<tr><td>3</td><td>10000001</td></tr>' '</tbody>')
def test_html_header(self): activation_code_html = model_html.ActivationCodeHtml( daos.TableDAO(table=self.table, user=self.owner)) self.assertEqual( activation_code_html.get_html_table_header(), '<thead><tr>' '<th>column_2</th>' '<th>Activation Code</th>' '</tr></thead>')