Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Modularize tests code #27

Merged
merged 2 commits into from
Jul 19, 2019
Merged

Modularize tests code #27

merged 2 commits into from
Jul 19, 2019

Conversation

nghnam
Copy link
Contributor

@nghnam nghnam commented Jul 19, 2019

Fix issue #26

Output

.2019-07-19 10:54:50,904 - INFO - test logprint
2019-07-19 10:54:50,904 - INFO - test log print
.....2019-07-19 10:54:50,906 - INFO - Model:
2019-07-19 10:54:50,906 - INFO - r.r: sub, obj, act
2019-07-19 10:54:50,906 - INFO - p.p: sub, obj, act
2019-07-19 10:54:50,906 - INFO - e.e: some(where (p_eft == allow))
2019-07-19 10:54:50,906 - INFO - m.m: r_sub == r_obj.Owner
2019-07-19 10:54:50,906 - INFO - Request: alice, {'Owner': 'alice', 'id': 'data1'}, write ---> True
............................
----------------------------------------------------------------------
Ran 34 tests in 0.022s

OK

Copy link
Member

@leeqvip leeqvip left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is no add_role_policy function, it is included in the add_policy function.
Modularize test cases are acceptable.

@hsluoyz
Copy link
Member

hsluoyz commented Jul 19, 2019

Hi @techoner , I think the current test_add_policy() only tests p policy. It doesn't test g policy.

def test_add_policy(self):
        m = Model()
        m.load_model(get_examples("basic_model.conf"))

        rule = ['admin', 'domain1', 'data1', 'read']

        self.assertFalse(m.has_policy('p', 'p', rule))

        m.add_policy('p', 'p', rule)
        self.assertTrue(m.has_policy('p', 'p', rule))

So add_role_policy() can test g. It's not bad.

@leeqvip
Copy link
Member

leeqvip commented Jul 19, 2019

@hsluoyz , It can be placed together in test_add_policy.

@hsluoyz
Copy link
Member

hsluoyz commented Jul 19, 2019

@techoner , OK, can you merge this PR then add a commit to merge this add_role_policy() function into add_policy() based on your point of view? I think it may be faster than letting the PR author modify it.

@leeqvip leeqvip merged commit 0ee5113 into casbin:master Jul 19, 2019
@hsluoyz hsluoyz mentioned this pull request Jul 19, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants