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

[qa] Move ReadOnlyAdmin to openwisp-utils #28

Merged
merged 1 commit into from
Dec 5, 2018
Merged

[qa] Move ReadOnlyAdmin to openwisp-utils #28

merged 1 commit into from
Dec 5, 2018

Conversation

strang1ato
Copy link
Contributor

Fixes #25

Copy link
Member

@nemesifier nemesifier left a comment

Choose a reason for hiding this comment

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

Good progress, see my comments, ensure to add an admin test which checks the fields are really read only

@@ -30,3 +30,135 @@ def __str__(self):

class Meta:
abstract = False


class AbstractRadiusAccounting(models.Model):
Copy link
Member

Choose a reason for hiding this comment

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

name it RadiusAccounting and simplify the fields, we don't need to have all the real fields, show just 3 or 4

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, I know it I feel that I understand ReadOnlyAdmin class well.
BTW you are really fast 😳

def save(self, *args, **kwargs):
if not self.start_time:
self.start_time = now()
super(AbstractRadiusAccounting, self).save(*args, **kwargs)
Copy link
Member

Choose a reason for hiding this comment

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

remove this

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Know it too I sent PR because in my local machine I was getting weird error:

from openwisp_utils.admin import (MultitenantAdminMixin, MultitenantOrgFilter,
ImportError: cannot import name 'ReadOnlyAdmin'

Copy link
Member

Choose a reason for hiding this comment

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

that's probably because of the modifications you have made in your previous task, check that

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@nemesisdesign For this task I am using unmarged version of repo (without my changes from previous task)

self.start_time = now()
super(AbstractRadiusAccounting, self).save(*args, **kwargs)

class Meta:
Copy link
Member

Choose a reason for hiding this comment

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

remove this Meta definition, it's not needed here

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I know it too as I said before I sent PR only because I wanted to check is above error occuring in travis too

Copy link
Member

Choose a reason for hiding this comment

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

can you now remove this please?

abstract = True

def __str__(self):
return self.unique_id
Copy link
Member

Choose a reason for hiding this comment

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

remove this as well

@strang1ato
Copy link
Contributor Author

Can somebody check travis, because there I can't reach radiusaccounting sites which normally I can easily reach by my webbrowser


def test_radiusaccounting_change(self):
options = dict(username='bobby', session_id='1')
obj = self._create_radius_accounting(**options)
Copy link
Member

Choose a reason for hiding this comment

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

you are getting redirected in the test to the login form because you have not logged-in as an admin, check out how other tests do this in this or other modules, is quite common

self.start_time = now()
super(AbstractRadiusAccounting, self).save(*args, **kwargs)

class Meta:
Copy link
Member

Choose a reason for hiding this comment

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

can you now remove this please?

@strang1ato strang1ato changed the title [WIP] [qa] Move ReadOnlyAdmin to openwisp-utils [qa] Move ReadOnlyAdmin to openwisp-utils Dec 3, 2018
@coveralls
Copy link

coveralls commented Dec 3, 2018

Coverage Status

Coverage increased (+1.4%) to 97.814% when pulling 58ac13d on OltarzewskiK:issues/25 into 2ea655a on openwisp:master.

Copy link
Member

@nemesifier nemesifier left a comment

Choose a reason for hiding this comment

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

You're almost done, see my last comment for the final cleanup

user = User.objects.create_superuser(username='administrator',
email='test@test.com',
password='admin')
self.client.force_login(user)
Copy link
Member

Choose a reason for hiding this comment

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

never duplicate code, it will set a bad precedent for future contributors, they will also start duplicating code if they see this, put these 2 lines in the setUp method of the test class, do you know what is that? If not, google it and read about it in the python docs, you will have learnt a new thing

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I haven't used setUp function because with that other tests were failing

Copy link
Member

Choose a reason for hiding this comment

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

in these case you can override it, eg:

def setUp(self):
    super().setup()
    # your own additional logic

Copy link
Member

@nemesifier nemesifier left a comment

Choose a reason for hiding this comment

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

@OltarzewskiK I merged some other PRs and now there are some conflicts, could you rebase your branch on the current master and fix the conflicts?

Copy link
Member

@nemesifier nemesifier left a comment

Choose a reason for hiding this comment

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

Good job! 👍

@nemesifier nemesifier merged commit 921cc11 into openwisp:master Dec 5, 2018
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.

None yet

3 participants