def test_create_valid_full(self): Route.objects.create(operator=Company.create_owned_company( name="Testbahn", abbrev="TB", owners=login_user(self)), name=self.DEMO_ROUTE_NAME, type=Route.LONG_DISTANCE, revenue_per_week=5000.00, start_date=now(), end_date=now() + timedelta(days=2 * 365))
def test_create_company_valid_two_owners(self): login_user(self) first_user = self.user login_user(context=self, username='******') second_user = self.user company = Company.create_owned_company(name="Testbahn", abbrev="TB", owners=[first_user, second_user]) self.assertEquals(first_user.company_set.all().count(), 1) self.assertEquals(second_user.company_set.all().count(), 1) self.assertEquals(company.ownership.all().count(), 2)
def test_to_string_full(self): route = Route(operator=Company.create_owned_company( name="Testbahn", abbrev="TB", owners=login_user(self)), name=self.DEMO_ROUTE_NAME, type=Route.LONG_DISTANCE, revenue_per_week=5000.00, start_date=now(), end_date=now() + timedelta(days=2 * 365)) self.assertEquals(route.__str__(), 'KBS 100 Hamburg - Rostock (Testbahn)')
def form_valid(self, form): Company.create_owned_company(form.data['name'], form.data['abbrev'], self.request.user) return redirect('index')
def test_create_company_to_string(self): login_user(self) company = Company.create_owned_company(name="TestBahn", abbrev="TB", owners=self.user) self.assertEquals(company.__str__(), "TestBahn (TB)")
def test_create_company_duplicate_abbrev(self): login_user(self) Company.create_owned_company(name="Testbahn", abbrev="TB", owners=self.user) with self.assertRaises(IntegrityError, msg="Adding a company with existing abbreviation, should not work"): Company.create_owned_company(name="Tolle Bahn", abbrev="TB", owners=self.user)
def test_create_company_valid_one_owner(self): login_user(self) Company.create_owned_company(name="Testbahn", abbrev="TB", owners=self.user) self.assertEquals(self.user.company_set.all().count(), 1)