Exemplo n.º 1
0
    def test_reverse_order_value(self):
        """Test receiving of companies with reversed order value."""

        query = CompaniesQuery({'order': '-employees__count'}, self.user_1)
        response = query.list()
        self.assertEqual([item.id for item in response], [
            self.company_2.id, self.company_1.id, self.company_3.id,
            self.company_4.id
        ])
Exemplo n.º 2
0
    def test_receiving_of_wrong_order(self):
        """Test receiving companies in case of the wrong order value."""

        query = CompaniesQuery({'order': 'title'}, self.user_1)
        response = query.list()
        self.assertEqual([item.id for item in response], [
            self.company_1.id, self.company_2.id, self.company_3.id,
            self.company_4.id
        ])
Exemplo n.º 3
0
    def test_setting_of_order(self):
        """Test receiving of the companies in particular order."""

        query = CompaniesQuery({'order': 'employees__count'}, self.user_1)
        response = query.list()
        self.assertEqual([item.id for item in response], [
            self.company_4.id, self.company_1.id, self.company_3.id,
            self.company_2.id
        ])
Exemplo n.º 4
0
    def test_receiving_of_companies_list(self):
        """Test of receiving of the companies list."""

        query = CompaniesQuery({}, self.user_1)
        response = query.list()
        self.assertEqual([item.id for item in response], [
            self.company_1.id, self.company_2.id, self.company_3.id,
            self.company_4.id
        ])
Exemplo n.º 5
0
    def test_receiving_of_empty_role(self):
        """Test receiving of companies list if role is None."""

        query = CompaniesQuery({'role': None}, self.user_1)
        response = query.list()
        self.assertEqual([item.id for item in response], [
            self.company_1.id, self.company_2.id, self.company_3.id,
            self.company_4.id
        ])
Exemplo n.º 6
0
    def test_setting_of_role(self):
        """Test receiving of companies for the role of current user."""

        query = CompaniesQuery({'role': CompanyMember.COMPANY_OWNER},
                               self.user_1)
        response = query.list()
        self.assertEqual(
            [item.id for item in response],
            [self.company_1.id, self.company_2.id, self.company_4.id])
Exemplo n.º 7
0
    def test_empty_order_value(self):
        """Test of receiving empty order value."""

        query = CompaniesQuery({'order': None}, self.user_1)
        response = query.list()
        self.assertEqual([item.id for item in response], [
            self.company_1.id, self.company_2.id, self.company_3.id,
            self.company_4.id
        ])