This repository has been archived by the owner on Jul 24, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2 from fedora-infra/feature/comma-delimited-detai…
…l-value Feature/comma delimited detail value
- Loading branch information
Showing
4 changed files
with
100 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
from nose.tools import eq_, assert_not_equals | ||
|
||
import os | ||
import fmn.lib.models | ||
import fmn.lib.tests | ||
|
||
|
||
class TestConfirmations(fmn.lib.tests.Base): | ||
def create_user_and_context_data(self): | ||
user1 = fmn.lib.models.User.get_or_create( | ||
self.sess, openid="ralph.id.fedoraproject.org", | ||
openid_url="http://ralph.id.fedoraproject.org/", | ||
) | ||
context1 = fmn.lib.models.Context.create( | ||
self.sess, name="irc", description="Internet Relay Chat", | ||
detail_name="irc nick", icon="user", | ||
) | ||
|
||
def create_preference_data_empty(self): | ||
user = fmn.lib.models.User.get( | ||
self.sess, openid="ralph.id.fedoraproject.org") | ||
context = fmn.lib.models.Context.get(self.sess, name="irc") | ||
preference = fmn.lib.models.Preference.create( | ||
self.sess, | ||
user=user, | ||
context=context, | ||
detail_value=None, | ||
) | ||
|
||
def test_updating_details(self): | ||
self.create_user_and_context_data() | ||
self.create_preference_data_empty() | ||
user = fmn.lib.models.User.get( | ||
self.sess, openid="ralph.id.fedoraproject.org") | ||
context = fmn.lib.models.Context.get(self.sess, name="irc") | ||
preference = fmn.lib.models.Preference.load(self.sess, user, context) | ||
preference.update_details(self.sess, 'wat') | ||
eq_(preference.detail_value, 'wat') | ||
preference.update_details(self.sess, 'wat2') | ||
eq_(preference.detail_value, 'wat,wat2') | ||
preference.update_details(self.sess, 'wat') | ||
eq_(preference.detail_value, 'wat,wat2') | ||
|
||
def test_confirmation(self): | ||
self.create_user_and_context_data() | ||
self.create_preference_data_empty() | ||
user = fmn.lib.models.User.get( | ||
self.sess, openid="ralph.id.fedoraproject.org") | ||
context = fmn.lib.models.Context.get(self.sess, name="irc") | ||
preference = fmn.lib.models.Preference.load(self.sess, user, context) | ||
confirmation = fmn.lib.models.Confirmation.create( | ||
self.sess, | ||
user, | ||
context, | ||
detail_value='awesome', | ||
) | ||
eq_(preference.detail_value, None) | ||
confirmation.set_status(self.sess, 'accepted') | ||
eq_(preference.detail_value, 'awesome') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters