/usr/lib/python2.7/dist-packages/fedmsg_meta_fedora_infrastructure/tests/tagger.py is in python-fedmsg-meta-fedora-infrastructure 0.2.18-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 | # This file is part of fedmsg.
# Copyright (C) 2013 Red Hat, Inc.
#
# fedmsg is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
# License as published by the Free Software Foundation; either
# version 2.1 of the License, or (at your option) any later version.
#
# fedmsg is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public
# License along with fedmsg; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
#
# Authors: Ralph Bean <rbean@redhat.com>
#
""" Tests for tagger messages """
import unittest
from fedmsg.tests.test_meta import Base
from common import add_doc
class TestTaggerVoteAuthenticated(Base):
""" `Fedora Tagger <https://apps.fedoraproject.org/tagger>`_
publishes messages like this one when a user votes on a tag.
Users may upvote or downvote a tag and they may do so either
anonymously or authenticated. Here's an example of an
authenticated downvote:
"""
expected_title = "fedoratagger.tag.update"
expected_subti = 'ralph downvoted "stupid" on mattd'
expected_link = 'https://apps.fedoraproject.org/tagger/mattd'
expected_icon = 'https://apps.fedoraproject.org/img/icons/tagger.png'
expected_secondary_icon = (
'https://seccdn.libravatar.org/avatar/'
'9c9f7784935381befc302fe3c814f9136e7a33953d0318761669b8643f4df55c'
'?s=64&d=retro')
expected_usernames = set(['ralph'])
expected_packages = set(['mattd'])
expected_objects = set(['packages/mattd', 'labels/stupid'])
msg = {
"i": 3,
"msg": {
"vote": {
"tag": {
"votes": 1,
"like": 0,
"package": "mattd",
"tag": "stupid",
"dislike": 1,
"total": -1
},
"like": False,
"user": {
"username": "ralph",
"votes": 4,
"rank": -1,
"anonymous": False
}
},
"tag": {
"votes": 1,
"like": 0,
"package": "mattd",
"tag": "stupid",
"dislike": 1,
"total": -1
},
"user": {
"username": "ralph",
"votes": 4,
"rank": -1,
"anonymous": False
}
},
"topic": "org.fedoraproject.dev.fedoratagger.tag.update",
"username": "threebean",
"timestamp": 1365444503.627384
}
class TestTaggerRatingUpdateAnonymous(Base):
""" `Fedora Tagger <https://apps.fedoraproject.org/tagger>`_
doesn't just do tagging of packages, in new versions it also
allows users to rate packages. It publishes messages like this
one when an anonymous user updates their rating of a package.
"""
expected_title = "fedoratagger.rating.update"
expected_subti = 'An anonymous user gave nethack a rating of 15'
expected_link = 'https://apps.fedoraproject.org/tagger/nethack'
expected_icon = 'https://apps.fedoraproject.org/img/icons/tagger.png'
expected_usernames = set([])
expected_packages = set(['nethack'])
expected_objects = set(['packages/nethack'])
msg = {
"i": 1,
"msg": {
"rating": {
"rating": 15,
"user": {
"username": "anonymous",
"votes": 0,
"anonymous": True,
"rank": -1
},
"package": {
"rating": 15.0,
"tags": [
{
"votes": 1,
"like": 1,
"package": "nethack",
"tag": "awesome",
"dislike": 0,
"total": 1
}
],
"name": "nethack",
"icon": "https://apps.fedoraproject.org/packages/images/"
"icons/package_128x128.png",
"summary": ""
}
}
},
"topic": "org.fedoraproject.dev.fedoratagger.rating.update",
"username": "threebean",
"timestamp": 1365514895.61764
}
class TestTaggerCreate(Base):
""" `Fedora Tagger <https://apps.fedoraproject.org/tagger>`_
publishes messages like this one when a user **creates** a new tag.
"""
expected_title = "fedoratagger.tag.create"
expected_subti = 'ralph added tag "awesome" to mattd'
expected_link = 'https://apps.fedoraproject.org/tagger/mattd'
expected_icon = 'https://apps.fedoraproject.org/img/icons/tagger.png'
expected_secondary_icon = (
'https://seccdn.libravatar.org/avatar/'
'9c9f7784935381befc302fe3c814f9136e7a33953d0318761669b8643f4df55c'
'?s=64&d=retro')
expected_usernames = set(['ralph'])
expected_packages = set(['mattd'])
expected_objects = set(['packages/mattd', 'labels/awesome'])
msg = {
"i": 2,
"msg": {
"vote": {
"tag": {
"votes": 1,
"like": 1,
"package": "mattd",
"tag": "awesome",
"dislike": 0,
"total": 1
},
"like": True,
"user": {
"username": "ralph",
"votes": 4,
"rank": -1,
"anonymous": False,
}
},
"tag": {
"votes": 1,
"like": 1,
"package": "mattd",
"tag": "awesome",
"dislike": 0,
"total": 1
},
"user": {
"username": "ralph",
"votes": 4,
"rank": -1,
"anonymous": False,
}
},
"topic": "org.fedoraproject.dev.fedoratagger.tag.create",
"username": "threebean",
"timestamp": 1365444411.924043
}
class TestTaggerVoteAnonymousLegacy(Base):
""" Support old legacy tagger messages. """
expected_title = "fedoratagger.tag.update"
expected_subti = 'anonymous upvoted "unittest" on perl-Test-Fatal'
expected_link = 'https://apps.fedoraproject.org/tagger/perl-Test-Fatal'
expected_icon = 'https://apps.fedoraproject.org/img/icons/tagger.png'
expected_usernames = set([])
expected_packages = set(['perl-Test-Fatal'])
expected_objects = set(['packages/perl-Test-Fatal', 'labels/unittest'])
msg = {
"i": 1,
"timestamp": 1345220838.2775879,
"topic": "org.fedoraproject.stg.fedoratagger.tag.update",
"msg": {
"vote": {
"tag": {
"votes": 2,
"like": 2,
"package": {
"perl-Test-Fatal": [
{
"dislike": 0,
"total": 1,
"tag": "perl",
"votes": 1,
"like": 1
},
{
"dislike": 0,
"total": 2,
"tag": "unittest",
"votes": 2,
"like": 2
}
]
},
"label": {
"label": "unittest",
"tags": [
{
"dislike": 0,
"total": 2,
"tag": "unittest",
"votes": 2,
"like": 2
}
]
},
"tag": "unittest",
"dislike": 0,
"total": 2
},
"like": True,
"user": {
"username": "anonymous",
"all_votes": [],
"votes": 0,
"rank": -1
}
}
}
}
class TestTaggerCreateLegacy(Base):
""" Support old TG2 version of tagger messages. """
expected_title = "fedoratagger.tag.create"
expected_subti = 'ralph added tag "unittest" to perl-Test-Fatal'
expected_link = 'https://apps.fedoraproject.org/tagger/perl-Test-Fatal'
expected_icon = 'https://apps.fedoraproject.org/img/icons/tagger.png'
expected_secondary_icon = (
'https://seccdn.libravatar.org/avatar/'
'9c9f7784935381befc302fe3c814f9136e7a33953d0318761669b8643f4df55c'
'?s=64&d=retro')
expected_usernames = set(['ralph'])
expected_packages = set(['perl-Test-Fatal'])
expected_objects = set(['packages/perl-Test-Fatal', 'labels/unittest'])
msg = {
"i": 1,
"timestamp": 1345220073.4948981,
"topic": "org.fedoraproject.stg.fedoratagger.tag.create",
"msg": {
"vote": {
"tag": {
"votes": 1,
"like": 1,
"package": {
"perl-Test-Fatal": [
{
"dislike": 0,
"total": 1,
"tag": "unittest",
"votes": 1,
"like": 1
},
{
"dislike": 0,
"total": 1,
"tag": "perl",
"votes": 1,
"like": 1
}
]
},
"label": {
"label": "unittest",
"tags": [
{
"dislike": 0,
"total": 1,
"tag": "unittest",
"votes": 1,
"like": 1
}
]
},
"tag": "unittest",
"dislike": 0,
"total": 1
},
"like": True,
"user": {
"username": "ralph",
"votes": 28,
"rank": 1
}
}
}
}
class TestTaggerToggleUsageOn(Base):
""" `Fedora Tagger <https://apps.fedoraproject.org/tagger>`_
publishes messages like this one when a user **toggles** their usage status
for a package.
Here is an example of ralph declaring that he uses *passwd*.
"""
expected_title = "fedoratagger.usage.toggle"
expected_subti = 'ralph declared that they use passwd'
expected_link = 'https://apps.fedoraproject.org/tagger/passwd'
expected_icon = 'https://apps.fedoraproject.org/img/icons/tagger.png'
expected_secondary_icon = (
'https://seccdn.libravatar.org/avatar/'
'9c9f7784935381befc302fe3c814f9136e7a33953d0318761669b8643f4df55c'
'?s=64&d=retro')
expected_usernames = set(['ralph'])
expected_packages = set(['passwd'])
expected_objects = set(['packages/passwd'])
msg = {
"username": "apache",
"i": 1,
"timestamp": 1391107443,
"msg_id": "2014-8b4ffffc-4854-4da5-92b1-d266b4e7f52f",
"topic": "org.fedoraproject.prod.fedoratagger.usage.toggle",
"msg": {
"usage": True,
"user": {
"username": "ralph",
"votes": 859,
"score": 949,
"anonymous": False,
"rank": 6
},
"package": {
"rating": -1.0,
"name": "passwd",
"tags": [],
"summary": "An utility for setting or changing passwords",
"usage": 1,
"icon": "https://apps.fedoraproject.org/packages/images/"
"icons/package_128x128.png"
}
}
}
class TestTaggerToggleUsageOff(Base):
""" `Fedora Tagger <https://apps.fedoraproject.org/tagger>`_
publishes messages like this one when a user **toggles** their usage status
for a package.
Here is an example of ralph declaring that he *no longer* uses *passwd*.
"""
expected_title = "fedoratagger.usage.toggle"
expected_subti = 'ralph declared that they no longer use passwd'
expected_link = 'https://apps.fedoraproject.org/tagger/passwd'
expected_icon = 'https://apps.fedoraproject.org/img/icons/tagger.png'
expected_secondary_icon = (
'https://seccdn.libravatar.org/avatar/'
'9c9f7784935381befc302fe3c814f9136e7a33953d0318761669b8643f4df55c'
'?s=64&d=retro')
expected_usernames = set(['ralph'])
expected_packages = set(['passwd'])
expected_objects = set(['packages/passwd'])
msg = {
"username": "apache",
"i": 1,
"timestamp": 1391107443,
"msg_id": "2014-8b4ffffc-4854-4da5-92b1-d266b4e7f52f",
"topic": "org.fedoraproject.prod.fedoratagger.usage.toggle",
"msg": {
"usage": False,
"user": {
"username": "ralph",
"votes": 859,
"score": 949,
"anonymous": False,
"rank": 6
},
"package": {
"rating": -1.0,
"name": "passwd",
"tags": [],
"summary": "An utility for setting or changing passwords",
"usage": 0,
"icon": "https://apps.fedoraproject.org/packages/images/"
"icons/package_128x128.png"
}
}
}
class TestTaggerRankUpdate(Base):
""" `Fedora Tagger <https://apps.fedoraproject.org/tagger>`_
publishes messages like this one when a user's rank on the Fedora Tagger
leaderboard changes.
"""
expected_title = "fedoratagger.user.rank.update"
expected_subti = "immanetize's rank changed to 59"
expected_icon = 'https://apps.fedoraproject.org/img/icons/tagger.png'
expected_secondary_icon = (
'https://seccdn.libravatar.org/avatar/'
'75aba49c572a4319af1792ba0dbe2a0d80de4dc1f602c43a360d9b0fc347ae0f'
'?s=64&d=retro')
expected_usernames = set(['immanetize'])
expected_packages = set()
expected_objects = set()
msg = {
"msg": {
"user": {
"anonymous": False,
"votes": 176,
"rank": 59,
"username": "immanetize",
"score": 275
}
},
"source_name": "datanommer",
"timestamp": 1396074860.0,
"topic": "org.fedoraproject.prod.fedoratagger.user.rank.update",
"source_version": "0.6.1",
"i": 1,
"msg_id": "2014-3893d29a-e9a1-43e0-90f0-333feebb766c"
}
add_doc(locals())
|